package lk.service.blogspringboot.mapper;

import lk.service.blogspringboot.domain.FollowingDetail;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 关注详细信息表(FollowingDetail)表数据库访问层
 *
 * @author LK
 * @since 2024-08-22 10:33:43
 */
@Mapper
public interface FollowingDetailMapper {

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    FollowingDetail queryById(Integer id);

    /**
     * 查询指定行数据
     *
     * @param followingDetail 查询条件
     * @return 对象列表
     */
    List<FollowingDetail> queryAll(FollowingDetail followingDetail);

    /**
     * 统计总行数
     *
     * @param followingDetail 查询条件
     * @return 总行数
     */
    long count(FollowingDetail followingDetail);

    /**
     * 新增数据
     *
     * @param followingDetail 实例对象
     * @return 影响行数
     */
    int insert(FollowingDetail followingDetail);

    /**
     * 批量新增数据（MyBatis原生foreach方法）
     *
     * @param entities List<FollowingDetail> 实例对象列表
     * @return 影响行数
     */
    int insertBatch(@Param("entities") List<FollowingDetail> entities);

    /**
     * 批量新增或按主键更新数据（MyBatis原生foreach方法）
     *
     * @param entities List<FollowingDetail> 实例对象列表
     * @return 影响行数
     * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常，请自行校验入参
     */
    int insertOrUpdateBatch(@Param("entities") List<FollowingDetail> entities);

    /**
     * 修改数据
     *
     * @param followingDetail 实例对象
     * @return 影响行数
     */
    int update(FollowingDetail followingDetail);

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 影响行数
     */
    int deleteById(Integer id);

    boolean deleteFollowingByUserNameAndFolloweeName(@Param("userName") String userName, @Param("followingUserName") String followingUserName);

    boolean queryIsFollowing(@Param("userName")String userName, @Param("followingUserName")String followingUserName);
}

